import java.util.Scanner;

public class a059_完全平方和 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int m;
		int cases;
		int a, b;
		int sum;
		
		while(sc.hasNext()) {
			m = sc.nextInt();
			cases = 0;
			
			for(int i = 0; i < m; i++) {
				cases ++;

				sc.nextLine();
				a = sc.nextInt();
				
				sc.nextLine();
				b = sc.nextInt();
				
				sum = 0;
				if(a == 1)
					sum += 1;
				for(int j = (int)Math.pow(a, 0.5) + 1; j <= (int)Math.pow(b, 0.5); j++) {
					sum += (int)Math.pow(j, 2);
				}
				
				System.out.println("Case " + Integer.toString(cases) + ": " + Integer.toString(sum));
			}
		}
	}
	
}